﻿using Google.GData.Calendar;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Web;


    public static class Extensions
    {
        public static IEnumerable<CalendarTransaction> ConvertToTransactions(this EventFeed calFeed)
        {
            CultureInfo provider = CultureInfo.InvariantCulture;
            return (from Google.GData.Calendar.EventEntry entry in calFeed.Entries
                    select new CalendarTransaction()
                    {
                        Date = entry.Times[0].StartTime,
                        Title = entry.Title.Text
                    });
        }
        public static T DeepClone<T>(T obj)
        {
            using (var ms = new MemoryStream())
            {
                var formatter = new BinaryFormatter();
                formatter.Serialize(ms, obj);
                ms.Position = 0;
                return (T)formatter.Deserialize(ms);
            }
        }
    }
